<?php

declare(strict_types=1);
/**
 * This file is part of MoChat.
 * @link     https://mo.chat
 * @document https://mochat.wiki
 * @contact  group@mo.chat
 * @license  https://github.com/mochat-cloud/mochat/blob/master/LICENSE
 */
namespace MoChat\App\WorkEmployee\Job;

use Hyperf\AsyncQueue\Job;
use Hyperf\Logger\LoggerFactory;
use MoChat\App\WorkEmployee\Logic\SyncEmployeeDetailLogic;

/**
 * 根据企业ID和wx员工id同步员工详情.
 */
class SyncEmployeeDetailJob extends Job
{
    /**
     * @var array
     */
    public $params;

    public function __construct(array $params)
    {
        $this->params = $params;
    }

    public function handle()
    {
        $corpId = (int) $this->params['corpId'];
        $wxEmployeeId = (string) $this->params['wxEmployeeId'];
        $lastEmployee = (int) $this->params['lastEmployee'];

        $loggerFactory = make(LoggerFactory::class);
        $logger = $loggerFactory->get(__CLASS__);
        $logger->debug(sprintf('同步员工详情队列开始, 企业ID:%s, 员工ID:%s', (string) $corpId, (string) $wxEmployeeId));

        $syncEmployeeDetailLogic = make(SyncEmployeeDetailLogic::class);
        $syncEmployeeDetailLogic->handle($corpId, $wxEmployeeId, $lastEmployee);
    }
}
